package com.example.h9iserver.service.impl;

import com.example.h9iserver.domain.query.ChatCompletionQuery;
import com.example.h9iserver.service.ChatService;
import com.example.h9iserver.service.springAi.AiChatService;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

@Service
@RequiredArgsConstructor
public class ChatServiceImpl implements ChatService {

    private final AiChatService aiChatService;
    @Override
    public Flux<String> completionStream(ChatCompletionQuery chatCompletionQuery) {
        String message = chatCompletionQuery.getMessage();
        Long userId = chatCompletionQuery.getUserId();
        return aiChatService.streamChatWithMemory(
                userId,
                message);
    }

    @Override
    public String completion(ChatCompletionQuery chatCompletionQuery) {
        String message = chatCompletionQuery.getMessage();
        Long userId = chatCompletionQuery.getUserId();
        return aiChatService.chatWithChatMemory(
                userId,
                message);
    }
//    @Override
//    public String completion(ChatCompletionQuery chatCompletionQuery) {
//        String message = chatCompletionQuery.getMessage();
//        Long userId = chatCompletionQuery.getUserId();
//        return aiChatService.chatWithChatMemory(userId, message);
//    }
}
